/*
 * @Author: zxc
 * @Date: 2020-08-10 15:16:01
 * @LastEditTime: 2020-09-08 09:12:57
 * @LastEditors: zxc
 * @Description: 登陆组件
 */

import React,{memo} from "react";
import {Redirect} from 'react-router-dom'
import ParticlesBg from "particles-bg";
import "./index.less";
import LoginMain from "./login-layout/LoginMain";
import useActions from '../../hooks/useActions';
import { useSelector } from "react-redux";
import { loginActionPromise } from '../../redux/saga/actions/user';


interface IProps {}

const Login: React.FC<IProps> = (props) => {
  const {isLogin,loading} = useSelector((state:IState )=> state.user)
  const actions = useActions({
    // loginAction,
    loginActionPromise,
  })
  if(isLogin){
    return <Redirect to='/' />
  }
  return (
    <div className="login">
      <div className="login-layout">
        <div className="login-header"></div>
        <LoginMain fetch={actions.loginActionPromise} loading={loading} />
        <div className="login-footer"></div>
        <ParticlesBg type="lines" bg />
      </div>
    </div>
  );
};

export default memo(Login);